package com.mnsq.common.bean.enums;

/**
 * must add the element at last of the enum!!
 *
 * @author Administrator
 * @date 2019/3/17 0017
 */
public enum SubjectType {
    /**
     * 文章内容
     */
    SUBJECT_ARTICLE,
    /**
     * 例题内容
     */
    SUBJECT_EXAM,
    /**
     * 经验交流内容
     */
    SUBJECT_EXP,
    /**
     * 解决方案内容
     */
    SUBJECT_ANSWERS,
    /**
     * 职位信息
     */
    SUBJECT_JOBS;

    public static String getType(Integer type) {
        if (type == null) {
            return "other";
        }
        for (SubjectType st : SubjectType.values()) {
            if (st.ordinal() == type) {
                return st.toString();
            }
        }
        return "other";
    }

    public static boolean exists(Integer type) {
        if (type != null) {
            for (SubjectType st : SubjectType.values()) {
                if (st.ordinal() == type) {
                    return true;
                }
            }
        }
        return false;
    }

    public static Integer type(String code) {
        for (SubjectType st : SubjectType.values()) {
            if (st.toString().equals(code)) {
                return st.ordinal();
            }
        }
        return 0;
    }
}
